const prdServe = 'https://qb.wxlcoin.com/api';
const devServe = 'http://47.244.79.106/api';
const devServe2 = 'http://192.168.1.7/api';
// http://47.244.79.106/api

export default function http(url,type,param,callback){
	uni.request({
		url:devServe + url,
		method:type || 'GET',
		data:param,
		header:{'AUTHORIZATION': uni.getStorageSync('user_token')},//自定义请求头信息
		success:function (res) {
			if(res.statusCode === 500) {
				uni.showToast({
					title: "服务器错误，请稍后重试",
					mask: false,
					icon:'none',
					duration: 1000
				});
				return
			}
			// 没有登录
			if(res.data.type === '999'){
				uni.showModal({
					content: '您的账号出现异常，请重新登录',
					cancelText: "取消",
					confirmText: "确定",
					success: (val) => {
						uni.reLaunch({
							url: '/pages/login/index'
						})
					}
				})
				return
			}
			// 没有资金密码
			if(res.data.type === '998'){
				uni.redirectTo({
					url:'/pages/user/setFundsPass'
				})
				return
			}
			callback&&callback(res)
		},
		fail:() => {
			uni.showToast({
				title: "网络繁忙，请稍后重试",
				icon:'none',
				duration: 1500
			});
        }
	})
}